<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>广告管理</title>
<meta name="decorator" content="default" />
<%@include file="/WEB-INF/views/include/dialog.jsp"%>
<script type="text/javascript">
	$(document).ready(function() {
		$("#searchForm").validate();
	});
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}

	function getTableForm() {
		return document.getElementById('searchForm');
	}

	function optTopLevel() {
		var f = getTableForm();
		f.action = "${ctx}/myadvertise/myadvertisement/saveTopLevel";
		f.submit();
	}
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li>
		<li class="active"><a href="${ctx}/ad/adver/list">广告列表</a></li>
		<li><a href="${ctx}/ad/adver/form">广告添加</a></li>
	</ul>

	<form:form id="searchForm" modelAttribute="advertisement" action="${ctx}/ad/adver/list" method="post"
		class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		<input id="pageSize" name="pageSize" type="hidden"
			value="${page.pageSize}" />
		<label>名称 ：</label>
		<form:input path="name" htmlEscape="false" maxlength="50" class="input-small" />
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" />
<br/>
<br>
		<shiro:hasPermission name="newsmodel:update">
			<ul class="button-group">
				<li><label id="primaryl" class="button primary pill">批量</label></li>
				<shiro:hasPermission name="newsmodel:update">
					<li><input id="auditAll" class="button pill" type="button"
						value="保存排序" onclick="optTopLevel()" /></li>
				</shiro:hasPermission>
			</ul>
		</shiro:hasPermission>
	
		<tags:message content="${message}" />
		<table id="contentTable"
			class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th><input type="checkbox"
						onclick="Ck.checkbox('ids',this.checked)" /></th>
					<th>广告位名称</th>
					<th>名称</th>
					<th>点击数/展示数</th>
					<th>有效期</th>
					<th>链接地址</th>
					<th>排序</th>
						<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${page.list}" var="advertisement">
					<tr>
						<td><input type='checkbox' name='ids'
							value='${advertisement.id}'
							onclick="Ck.selectCheckBox('${advertisement.id}',this.checked)" /></td>
						<td>${advertisement.spaceId}</td>
						<td><a
							href="${ctx}/ad/adver/form?id=${advertisement.id}">${advertisement.name}</a></td>

						<td>${advertisement.clickCount}/${advertisement.displayCount}</td>
						<td>${advertisement.startTime}～${advertisement.endTime}</td>
						<td>${advertisement.url}</td>
						<td style="text-align: center;">
						<shiro:hasPermission
								name="adspagemg:update">
								<input type="hidden" name="wids" value="${advertisement.id}" />
								<input name="orders" type="text"
									value="${advertisement.orderId}"  class="digits" 
									style="width: 50px; margin: 0; padding: 0; text-align: center;">
							</shiro:hasPermission> <shiro:lacksPermission name="adspagemg:update">
							${advertisement.orderId}
						</shiro:lacksPermission>
						</td>
						
							<td>
							<c:if test="${advertisement.isEnable eq '0'}">
								<a href="${ctx}/ad/adver/enable?id=${advertisement.id}">启用</a>
							</c:if>
							<c:if test="${advertisement.isEnable ne '0'}">已启用</c:if>
							<a href="${ctx}/ad/adver/form?id=${advertisement.id}">修改</a>
							<a href="${ctx}/ad/adver/delete?id=${advertisement.id}"
								onclick="return confirmx('确认要删除该广告吗？', this.href)">删除</a>
							</td>
						
					</tr>
				</c:forEach>
			</tbody>
		</table>

	</form:form>

<span style="color:red">注: 只能是数字，有大到小排序</span>
	<div class="pagination">${page}</div>
			
</body>
</html>
